<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org/">
<head>
    <meta charset="utf-8">
    <title>心理疾病自检与互助平台</title>
<!--    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>-->
<!--    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">-->
<!--    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>-->

    <link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <style>
        .avator {
            width: 250px;
            height: 300px;
            border: 1px solid #e8e8e8;
            border-radius: 5px;
            margin: 200px auto auto auto;
            text-align: center;
        }

        .avator img {
            border: 1px solid #f1f1f1;
            width: 180px;
            height: 180px;
            margin-top: 5px;
        }

        .avator form {
            margin-top: 20px;
            height: 100px;
        }

        .avator form input {
            width: 60%;
            border: none;
            outline: none;
            background-color: #e4b9b9;
            margin: 5px auto;
            border-radius: 2px;
        }

        .avatortip {
            font-size: smaller;
            visibility: hidden;
        }

    </style>

</head>
<body>
<option class="form-control" id="userart"  name="niyaya" value="33">nihao</option>
<input type="button" class="form-control" id="userart1" text="${user.getName()}" value="${user.getId()}">
</body>

<script>

    alert($("#userart").val())
    function uploadAvator() {
        console.log(new FormData($('#uploadForm')[0]))
        $.ajax({
            type: 'post',
            url: '/uploadavator',
            data: new FormData($('#uploadForm')[0]),
            processData: false,
            contentType: false,
            success: function (rescode) {
                if (rescode == '200') {
                    setTimeout(function () {
                        $("#avatortip").html('<div style="color: #3bbb3b">更换成功，页面即将跳转</div>').css("visibility", "visible")
                    }, 2000)
                    window.location.href = "/user/";
                } else {
                    $("#avatortip").html('<div style="color: #cd1a29">更换失败，请重试</div>').css("visibility", "visible");
                }
            },
            error: function () {

                $("#avatortip").html('<div style="color: #cd0404">更换失败，请重试</div>').css("visibility", "visible");
            }
        });
    }
</script>

</html>
<!--<form action="/uploadavator" method="post" enctype="multipart/form-data">-->
<!--    <input type="file" name="file" accept="image/*"/>-->
<!--    <input type="submit" class="btn btn-primary btn-sm" value="上传" onclick="uploadAvator()">-->
<!--</form>-->
